package Java0108;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class Test04 {
    public static void main(String[] args) {

    }


    class server {
        ServerSocket serverSocket = new ServerSocket(8081);

        server() throws IOException {

            Socket socket = serverSocket.accept();
            InputStream inputStream = socket.getInputStream();
            byte[] arr = new byte[1024];
            int len = inputStream.read(arr);
            System.out.println(new String(arr, 0, len));

        }
    }
}
class Client1{
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",8081);
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("1234".getBytes(StandardCharsets.UTF_8));

    }
    }

